package com.onjob.photo;



import org.hibernate.Query;

import com.onjob.employment.Resume;



import util.dao.HibernateDaoImpl;


public class PhotoDaoImpl extends HibernateDaoImpl<Photo,String> implements PhotoDao {

	public Photo findByResumeId(String resumeId) {
		Query query = this.getSession().createQuery(
				"from " + Photo.class.getName()
						+ " p where p.resumeId.id=:resumeId");
		query.setParameter("resumeId", resumeId);
		return (Photo) query.uniqueResult();
	}

	@Override
	public Photo findPhotoByType(String string, String type) {
		
			Query query = this.getSession().createQuery(
					" from " + Photo.class.getName() + " p where p."+type+"=:type");
			query.setString("type", string);
			
			return (Photo) query.uniqueResult();
		
	}

	@Override
	public boolean isFindPhotoByResumeId() {
		
		return false;
	}

	@Override
	public Photo findPhotoByTypes(String string1,String string2, String type1, String type2) {
		Query query = this.getSession().createQuery(
				" from " + Photo.class.getName() + " p where p."+type1+"=:type1 and p."+type2+"=:type2");
		query.setString("type1", string1);
		query.setString("type2", string2);
		
		return (Photo) query.uniqueResult();
	}

	
	
	
}
